package com.wyl.base.bean

import android.graphics.Color
import androidx.databinding.BaseObservable
import androidx.databinding.Bindable
import com.google.gson.annotations.SerializedName
import com.wyl.base.BR
import com.wyl.base.R
import java.io.Serializable

class VideoData : Serializable, BaseObservable() {

    /** 是否推送收藏 1否 2是 */
    @Bindable
    var selected: Boolean = false
        set(value) {
            field = value
            notifyPropertyChanged(BR.selected)
        }

    /** 番剧的id */
    @SerializedName("appFolkOperaId")
    var appFolkOperaId: String = ""

    /** 是否推送收藏 1否 2是 */
    @Bindable
    @SerializedName("status", alternate = ["pushStatus"])
    var status: Int = 1
        set(value) {
            field = value
            notifyPropertyChanged(BR.status)
        }

    /** 番剧名称 */
    @SerializedName("operaName", alternate = ["name"])
    var operaName: String = ""

    @SerializedName("details")
    var details: List<VideoData>? = null

    @SerializedName("week")
    var week: String = ""

    /** "第一集",//剧集名称 */
    @SerializedName("VideoName", alternate = ["videoName"])
    var videoName: String = ""

    @SerializedName("time")
    var time: String = ""
    @SerializedName("updateType")
    var updateType: Int = 0

    @SerializedName("remarks")
    var remarks: String = "0"

    @SerializedName("currentTime")
    var currentTime: String = "0"

    // 选集
    /** 封面图 */
    @SerializedName("appUrl", alternate = ["appcover", "cover"])
    var appUrl: String = ""

    /** 视频播放路径 */
    @SerializedName("videourl")
    var videourl: String = ""

    /** 1可以播放2不能播放 */
    @SerializedName("playType")
    var playType: Int = 0

    /** 剧集id */
    @SerializedName("appVideoId", alternate = ["app_video_id"])
    var appVideoId: String = ""

    /** 第几集 */
    @SerializedName("number")
    var number: String = ""

    @Bindable
    var playing: Boolean = false
        set(value) {
            field = value
            notifyPropertyChanged(BR.playing)
        }

    //    打赏相关
    @SerializedName("goldcoin")
    var goldcoin: String = ""
    @SerializedName("createDate")
    var createDate: String = ""
        get() = "打赏时间: $field"


    // 详情
    /** 番剧简介内容*/
    @SerializedName("introductioncontent")
    var introductioncontent: String = ""

    /** 番剧简介图片 图片是多张以|分割*/
    @SerializedName("introductionpicture")
    var introductionpicture: String = ""

    /** 更新到第几集*/
    @SerializedName("toupdateepisode")
    var toupdateepisode: String = "0"

    /** 总集数*/
    @SerializedName("episode")
    var episode: String = "0"

    /** 热度*/
    @SerializedName("popularity")
    var popularity: String = "0"

    /**
     * 番剧类型 eg:动作
     *
     * 1:本周 2:下周
     *
     * */
    @SerializedName("type")
    var type: String = ""


    // 广告
    /** 广告图片 */
    @SerializedName("picture")
    var picture: String = ""

    /** 广告时长 */
    @SerializedName("second")
    var second: String = "0"

    /** 广告链接 */
    @SerializedName("url")
    var url: String = ""


    /* *********************  收藏 ***************************** */
    @SerializedName("id")
    var id = ""

    var group: String = ""

    fun getTimeAndVideoName(): String {
        if (appVideoId == "1") {
//            videoName = "无剧集"
            time = ""
        }
        return time + "\n" + videoName
    }


    fun getIsCollect(i: Int): Boolean = i == 2

    fun getOpAndVideoName(videoName: String, noName: String): String {
        return "$videoName 第${noName}集"
    }


    fun getProgress(i: String): String = "观看至$i%"

    fun getIntroductionPicList(pics: String) = pics.split("|")

    fun getTimeAndNameColor(): Int {
        return when {
            updateType == 1 -> Color.parseColor("#FFA2B1")
            playType == 1 -> Color.parseColor("#333333")
            else -> Color.parseColor("#cccccc")
        }
    }
}

